//
//  NavigationController.swift
//  MoyoungCommon
//
//  Created by 李然 on 2022/7/19.
//

import UIKit
import EachNavigationBar
import MoyoungLib

open class NavigationController: UINavigationController {
    
    open override func viewDidLoad() {
        super.viewDidLoad()
        
        navigation.configuration.isEnabled = true
        navigation.configuration.isTranslucent = false
        navigation.configuration.isShadowHidden = true
        navigation.configuration.barTintColor = R.color.common_2_bg_page()
        navigation.configuration.tintColor = R.color.common_3_text()
        navigation.configuration.backItem = UINavigationController.Configuration.BackItem.init(style: .image(R.image.ic_common_nav_back()))
        navigation.configuration.titleTextAttributes = [.foregroundColor: R.color.common_3_text() ?? .clear,
                                                        .font: Fonts.mediumSystemFont(ofSize: 18)]
    }
    
    open override var preferredStatusBarStyle: UIStatusBarStyle {
        return self.topViewController?.preferredStatusBarStyle ?? .default
    }
    
    open override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count >= 1 {
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }
}
